﻿<%@ Import Namespace="NetDon.OA.Interface.Configuration" %>
<%@ Import Namespace="NetDon.Utilities" %>
<%@ Import Namespace="NetDon.OA.Interface" %>

<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="EventManage.aspx.cs" Inherits="NetDon.OA.Portal.Admin.EventManage" %>

<%@ Register Src="../Controls/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script language="javascript" type="text/javascript">
        function showEventView(eventId) {
            $dialog('<%= ResolveUrl(SiteUrls.Admin.EventView) %>?EventId=' + eventId, { width: 500, height: 500 });
        }
        function treeCategoriesSelectedNodeChanged() {
            $get('<%=btnChangeCategory.ClientID %>').click();
        }

        function showBulkDelete() {
            $dialog('<%= ResolveUrl(SiteUrls.Admin.EventBulkDelete) %>', { width: 500, height: 260 }, function (result) {
                if (result) {
                    $get('<%=btnSearch.ClientID %>').click();
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
                <tr>
                    <td valign="top" style="width: 150px">
                        <NineRays:FlyTreeView ID="treeCategories" runat="server" DrawLines="False" OnSelectedNodeChangedJavascript="treeCategoriesSelectedNodeChanged"
                            Height="300">
                        </NineRays:FlyTreeView>
                    </td>
                    <td valign="top">
                        <asp:Panel ID="Panel1" runat="server" DefaultButton="btnSearch">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                        <NetDon:FormPanel ID="PanelCondition" runat="server" CaptionAlign="NotSet" RepeatColumns="2">
                                            <Items>
                                                <NetDon:FormItem HeaderText="日志日期">
                                                    <ContentTemplate>
                                                        <asp:TextBox ID="txtStartDate" runat="server" Width="79px"></asp:TextBox>
                                                        <asp:CalendarExtender ID="txtStartDate_CalendarExtender" runat="server" Enabled="True"
                                                            TargetControlID="txtStartDate" Format="yyyy-MM-dd">
                                                        </asp:CalendarExtender>
                                                        <asp:Label ID="lbend" runat="server" Text="~"></asp:Label>
                                                        <asp:TextBox ID="txtEndDate" runat="server" Width="79px"></asp:TextBox>
                                                        <asp:CalendarExtender ID="txtEndDate_CalendarExtender" runat="server" Enabled="True"
                                                            TargetControlID="txtEndDate" Format="yyyy-MM-dd">
                                                        </asp:CalendarExtender>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <%--  <NetDon:FormItem HeaderText="Application">
                                                    <ContentTemplate>
                                                        <asp:DropDownList ID="ddlApplication" runat="server" AppendDataBoundItems="True"
                                                            DataSourceID="ObjectDataSourceApplication" DataTextField="ApplicationName" DataValueField="ApplicationName">
                                                        </asp:DropDownList>
                                                        <asp:ObjectDataSource ID="ObjectDataSourceApplication" runat="server" OldValuesParameterFormatString="original_{0}"
                                                            SelectMethod="RetrieveApplications" TypeName="NetDon.OA.Business.MiscDataSource">
                                                            <SelectParameters>
                                                                <asp:Parameter DefaultValue="true" Name="includeAdministration" Type="Boolean" />
                                                            </SelectParameters>
                                                        </asp:ObjectDataSource>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>--%>
                                                <NetDon:FormItem HeaderText="日志类型">
                                                    <ContentTemplate>
                                                        <asp:DropDownList ID="ddlLogLevel" runat="server" CausesValidation="True" DataSourceID="EnumDataSource1"
                                                            DataTextField="Description" DataValueField="Name">
                                                        </asp:DropDownList>
                                                        <NetDon:EnumDataSource ID="EnumDataSource1" runat="server" EmptyItemType="All" TypeName="NetDon.OA.Interface.LogLevel">
                                                        </NetDon:EnumDataSource>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                                <NetDon:FormItem HeaderText="用户名">
                                                    <ContentTemplate>
                                                        <asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
                                                    </ContentTemplate>
                                                </NetDon:FormItem>
                                            </Items>
                                        </NetDon:FormPanel>
                                    </td>
                                    <td valign="bottom" style="padding-left: 10px">
                                        <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" Text="查询"></asp:Button>
                                        <asp:Button ID="btnDelete" runat="server" Style="margin-left: 10px" OnClientClick="showBulkDelete();return false;"
                                            SkinID="Button80" Text="批量删除"></asp:Button>
                                    </td>
                                </tr>
                            </table>
                        </asp:Panel>
                        <div style="margin-top: 10px">
                            <NetDon:GridView ID="gridLogs" runat="server" AutoGenerateColumns="False" AllowSorting="true"
                                OnRowDataBound="gridLogs_RowDataBound" OnRowCommand="gridLogs_RowCommand">
                                <Columns>
                                    <NetDon:TemplateField HeaderText="日志类型" SortExpression="Type" ItemStyle-Width="100px">
                                        <ItemTemplate>
                                            <asp:Image ID="Image1" runat="server" SkinID="Success" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.SuccessAudit %>' />
                                            <asp:Image ID="Image2" runat="server" SkinID="Failure" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.FailureAudit %>' />
                                            <asp:Image ID="Image3" runat="server" SkinID="Logout" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.Logout %>' />
                                            <asp:Image ID="Image4" runat="server" SkinID="Error" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.Error %>' />
                                         <%--   <asp:Image ID="Image5" runat="server" SkinID="Information" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.Information %>' />
                                            <asp:Image ID="Image6" runat="server" SkinID="Warning" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.Warning %>' />--%>
                                              <asp:Image ID="Image7" runat="server" SkinID="Success" Visible='<%# (LogLevel)(int)Eval("Level")==LogLevel.Workflow %>' />
                                            <%# EnumUtilities.GetDescription((LogLevel)(int)Eval("Level"))%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="日志时间" SortExpression="LogTime" ItemStyle-Width="120px">
                                        <ItemTemplate>
                                            <%# Eval("LogTime","{0:"+SystemConfiguration.DateTimeFormat+"}") %>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:TemplateField HeaderText="日志来源" SortExpression="Source" ItemStyle-Width="300px">
                                        <ItemTemplate>
                                            <%# Eval("Source")%>
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                    <NetDon:BoundField HeaderText="用户名" DataField="UserName" SortExpression="User" />
                                <%--    <NetDon:BoundField HeaderText="应用程序名称" DataField="ApplicationName" SortExpression="Application" />--%>
                                    <NetDon:TemplateField HeaderText="操作" ItemStyle-Width="60px">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="btnView" runat="server" SkinID="ViewDetail" />
                                            <asp:ImageButton ID="btnDelete" runat="server" CommandArgument='<%# Eval("LogId") %>'
                                                CommandName="DeleteEvent" SkinID="Delete" />
                                        </ItemTemplate>
                                    </NetDon:TemplateField>
                                </Columns>
                            </NetDon:GridView>
                        </div>
                        <asp:Button ID="btnChangeCategory" runat="server" OnClick="btnChangeCategory_Click"
                            SkinID="Hidden" />
                        <uc1:GridPager ID="pagerLogs" runat="server" TargetControlID="gridLogs" OnPerformGetCondition="pagerLogs_PerformGetCondition"
                            OnPerformGetPageData="pagerLogs_PerformGetPageData" OnPerformGetRecordCount="pagerLogs_PerformGetRecordCount" />
                    </td>
                </tr>
            </table>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
